import pymysql
try:
    connect=pymysql.connect(host='127.0.0.1',
                            user='root',
                            password='admin',
                            db='spider',
                            charset='utf8')
    cursor=connect.cursor()
    sql='insert into teacherinfo(tno,tname,remark) values("000250","何凤","人机---学艺不精")'
    cursor.execute(sql)
    connect.commit()
except Exception as e:
    connect.rollback()
    print(e)
finally:
    cursor.close()
    connect.close()